{% extends "base.html" %}
{% load mezzanine_tags keyword_tags %}
{% load article_tags %}

{% block meta_title %}{{ object.meta_title }}{% endblock %}

{% block meta_keywords %}{% metablock %}
    {% keywords_for object as keywords %}
    {% for keyword in keywords %}
        {% if not forloop.first %}, {% endif %}
        {{ keyword }}
    {% endfor %}
{% endmetablock %}{% endblock %}

{% block meta_description %}{% metablock %}
    {{ object.description }}
{% endmetablock %}{% endblock %}

{% block title %}
    {% keywords_for object as keywords %}
    <a href="{{ object.category.get_absolute_url }}">{{ object.category.title }}</a>
    <div class="article-title">
        {% if keywords %}
            {% spaceless %}
                <ul>
                    {% for keyword in keywords %}
                        {% if forloop.counter <= 5 %}
                            <li><a href="{% url 'article_tag' tag=keyword.title %}">{{ keyword.title }}</a></li>
                        {% endif %}
                    {% endfor %}
                </ul>
            {% endspaceless %}
        {% endif %}
    </div>
{% endblock %}

{% block main %}
    <div class="article-header">
        <h1 class="title">{{ object.title }}</h1>

        <div>
            <span class="muted">时间：{{ object.publish_date|date }}</span>
            <span class="muted">来源：</span>{{ object.author }}

        </div>
    </div>
    <div class="article-body">
        {{ object.body|safe }}
    </div>

    <ul class="pager">
        <li class="previous">
            {% load_previous_article object as previous_article %}
            {% if previous_article %}
                <a href="{{ previous_article.get_absolute_url }}">&larr; {{ previous_article.title }}</a>
            {% endif %}
        </li>
        <li class="next">
            {% load_next_article object as next_article %}
            {% if next_article %}
                <a href="{{ next_article.get_absolute_url }}">{{ next_article.title }} &rarr;</a>
            {% endif %}
        </li>
    </ul>

    {% load rating_tags %}

    {% rating_for object %}
    {% load comment_tags %}
    {% comments_for object %}

    {% if object.get_related %}
        <div class="article-related panel">
            <h2>相关阅读</h2>
            <ul>
                {% for item in object.get_related %}
                    <li><a href="{{ item.get_absolute_url }}">{{ item.title }}</a>
                        <small><span class="muted">{{ item.publish_date|date }}</span></small>
                    </li>
                {% endfor %}
            </ul>
        </div>
    {% endif %}

{% endblock %}


